package com.example.process.node.enums;

import com.example.process.node.NodeProcessor;
import com.example.process.node.template.RawMaterialStandardTemplate;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
/**
 * @author tangsen2333
 * @date 2022/6/15
 * @description 流程模板分类
 */
@Getter
@AllArgsConstructor
public enum ProcessTemplateEnum {

    RAW_MATERIAL_STANDARD_TEMPLATE(10, RawMaterialStandardTemplate.class, new ConcurrentHashMap());;

    private Integer templateCode;

    private Class templateClass;

    private Map<Integer, NodeProcessor> nodeMap;


    public static Class getTemplateClassByTemplateType(Integer templateCode) {
        for (ProcessTemplateEnum value : ProcessTemplateEnum.values()) {
            if (Objects.equals(value.getTemplateCode(), templateCode)) {
                return value.getTemplateClass();
            }
        }
        return null;
    }
}
